<h1>Payment File</h1>
<?php 
    if($payment){
        if ($payment->role_document==DOCUMENT_FREIGHTINVOICE){$title_document = 'document freight invoice';}
        $tempsession = $this->session->userdata('user');
        if($tempsession['role_id']==ROLE_CONSIGNEE){
            $path = 'assets/documents/process/Consignee/'.$tempsession['username'].'/Sent';
        }else if($tempsession['role_id']==ROLE_SHIPPINGLINE){
            $path = 'assets/documents/process/ShippingLine/'.$tempsession['username'].'/Sent';
        }else if($tempsession['role_id']==ROLE_OPERATORTERMINAL){
            $path = 'assets/documents/process/OperatorTerminal/'.$tempsession['username'].'/Sent';
        }else if($tempsession['role_id']==ROLE_TRUCKING){
            $path = 'assets/documents/process/Trucking/'.$tempsession['username'].'/Sent';
        }else if($tempsession['role_id']==ROLE_INSW){
            $path = '.././insw/assets/documents/process/INSW/INSW/Sent';
        }
        $full_path = $path.'/'.$payment->file_url;
        if(file_exists($full_path)){
            $file_path = base_url().$path.'/'.$payment->file_url;
        }else{
            $sub_path = substr($path,0,-4);
            $file_path = base_url().$sub_path.'Inbox/'.$payment->file_url;
        }
    ?>
<fieldset>
<legend>Data</legend>
<table>
    <tr>
        <td><label>Creation Date</label></td>
        <td><label><?php echo $payment->CreationDate;?></label></td>
    </tr>
    <tr>
        <td><label>Invoice</label></td>
        <td><a target="_blank" href="<?php echo base_url();?>message/view_document_page/<?php echo $payment->role_document.'/'.$payment->document_id;?>"><label><?php echo 'View '.$title_document;?></label></a></td> 
    </tr>
    <tr>
        <td>Payment File</td>
        <td></td>
    </tr>
    <tr>
        <td><img src="<?php echo $file_path;?>" weight='360px' height='480px' /></td>
    </tr>
    <?php if($payment->role_document==DOCUMENT_FREIGHTINVOICE && $tempsession['role_id']==ROLE_SHIPPINGLINE){
            ?>
        <?php if($document['data']->PaymentStatus!=ACTION_APPROVE){
        ?>
    <tr>
        <td>Approvement :</td>
        <td></td>
    </tr>
    <tr>
        <td><form action="<?php echo base_url().'message/update_approvement_invoice'?>" method="POST"><input type="hidden" name="payment_id" value="<?php echo $payment->payment_id;?>" /><input type="hidden" name="role_document" value="<?php echo $payment->role_document;?>" /><input type="hidden" name="document_id" value="<?php echo $payment->document_id;?>" /><input type="hidden" name="action" value="<?php echo ACTION_APPROVE;?>" /><input id="formloginbutton" type="submit" value="Approve" /></form></td>
        <td><form action="<?php echo base_url().'message/update_approvement_invoice'?>" method="POST"><input type="hidden" name="payment_id" value="<?php echo $payment->payment_id;?>" /><input type="hidden" name="role_document" value="<?php echo $payment->role_document;?>" /><input type="hidden" name="document_id" value="<?php echo $payment->document_id;?>" /><input type="hidden" name="action" value="<?php echo ACTION_REJECT;?>" /><input id="formloginbutton" type="submit" value="Reject" /></form></td>
    </tr>
        <?php }else{ ?>
    <tr>
        <td><label>Approvement :</label></td>
        <td><label>Approved</label></td>
    </tr>
    <?php } 
    }?>
</table>
</fieldset>
<br/>
<?php } ?>